<!--
 * @Author: JiraiyaChen 979526234@qq.com
 * @Date: 2025-07-25 16:43:44
 * @LastEditors: JiraiyaChen 979526234@qq.com
 * @LastEditTime: 2025-07-28 13:37:31
 * @Description: 废标模板
-->

<template>
  <div class="reject-template">
    <div class="title">
      <span>
        {{ componentName }}
      </span>
    </div>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="项目名称">
        {{ staticData.projectName }}
      </el-descriptions-item>
      <el-descriptions-item label="项目编号">
        {{ staticData.projectNumber }}
      </el-descriptions-item>
      <el-descriptions-item label="招标公告刊登的媒体名称">
        <el-checkbox-group v-model="staticData.mediaNameSelect">
          <el-checkbox v-for="item in mediaNameList" :key="item" :label="item" :value="item">{{ item }}</el-checkbox>
        </el-checkbox-group>
        <el-input v-model="staticData.mediaNameInput" placeholder="请填写招标公告刊登的媒体名称" clearable />
      </el-descriptions-item>
      <el-descriptions-item label="开标日期">
        {{ storeData.openBidTime }}
      </el-descriptions-item>
      <el-descriptions-item label="开标地点">
        {{ storeData.openBidPlace }}
      </el-descriptions-item>
      <el-descriptions-item label="废标原因">
        {{ staticData.deprecatedReason }}
      </el-descriptions-item>
    </el-descriptions>
    <div class="flex items-center justify-center mt-4">
      <el-button type="primary" @click="handleSave">提交</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { handleMediaNameSelect, mediaNameList } from './data'
import { getReviewReportDynamicValue, updateReviewReportDynamicValue } from '@/api/review-report-generation'

defineProps({
  componentName: {
    type: String,
    default: ''
  }
})

const storeData = useProjectInfoStore().projectInfo

onMounted(() => {
  getStaticData()
})
const staticData = ref<any>({})
const getStaticData = async () => {
  const res: any = await getReviewReportDynamicValue()
  staticData.value.mediaNameInput = res.mediaNameInput
  staticData.value.mediaNameSelect = handleMediaNameSelect(res.mediaNameSelect)
  staticData.value.projectName = res.projectName
  staticData.value.projectNumber = res.projectNumber
  staticData.value.deprecatedReason = res.deprecatedReason
}

const handleSave = async () => {
  const apiData = cloneDeep(staticData.value)
  apiData.mediaNameSelect = apiData.mediaNameSelect.join(',')
  await updateReviewReportDynamicValue(apiData)
  await getStaticData()
}
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>
